package org.tigris.subversion.svnant.commands;

import java.io.File;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.tigris.subversion.svnant.SvnAntUtilities;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNRevision;
import org.tigris.subversion.svnclientadapter.SVNUrl;

public class Checkout extends SvnCommand
{
  private static final String MSG_CHECKOUT_FAILED = "Can't checkout";
  private static final String MSG_USAGE_CONFLICT = "The option 'recurse' cannot be used together with 'depth' ! Ignoring 'recurse' !";
  private SVNUrl url = null;
  private Boolean recurse = null;
  private File destPath = null;
  private SVNRevision revision = SVNRevision.HEAD;
  private boolean force = false;
  private boolean ignoreexternals = false;
  private CheckoutDepth depth = null;

  public void execute()
  {
    if (this.destPath == null)
      this.destPath = getProject().getBaseDir();
    try
    {
      if (this.depth != null)
        getClient().checkout(this.url, this.destPath, this.revision, this.depth.getIntValue(), this.ignoreexternals, this.force);
      else
        getClient().checkout(this.url, this.destPath, this.revision, this.recurse == null ? true : this.recurse.booleanValue());
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Can't checkout", new Object[0]);
    }
  }

  protected void validateAttributes()
  {
    if (this.destPath != null)
      SvnAntUtilities.attrNotNull("destpath", this.destPath);
    SvnAntUtilities.attrNotNull("url", this.url);
    SvnAntUtilities.attrNotNull("revision", this.revision);
    if ((this.depth != null) && (this.recurse != null))
      warning("The option 'recurse' cannot be used together with 'depth' ! Ignoring 'recurse' !", new Object[0]);
  }

  public void setRecurse(boolean paramBoolean)
  {
    this.recurse = Boolean.valueOf(paramBoolean);
  }

  public void setForce(boolean paramBoolean)
  {
    this.force = paramBoolean;
  }

  public void setIgnoreExternals(boolean paramBoolean)
  {
    this.ignoreexternals = paramBoolean;
  }

  public void setDepth(CheckoutDepth paramCheckoutDepth)
  {
    this.depth = paramCheckoutDepth;
  }

  public void setUrl(SVNUrl paramSVNUrl)
  {
    this.url = paramSVNUrl;
  }

  public void setDestpath(File paramFile)
  {
    this.destPath = paramFile;
  }

  public void setRevision(String paramString)
  {
    this.revision = getRevisionFrom(paramString);
  }

  public static class CheckoutDepth extends EnumeratedAttribute
  {
    private static final String MSG_UNSUPPORTED_DEPTH_VALUE = "Unsupported 'depth' value: '%s'";
    private static final String[] VALUES = { "empty", "files", "immediates", "infinity" };
    private static final int[] IVALUES = { 0, 1, 2, 3 };

    public String[] getValues()
    {
      return VALUES;
    }

    public int getIntValue()
    {
      for (int i = 0; i < VALUES.length; i++)
        if (VALUES[i].equalsIgnoreCase(getValue()))
          return IVALUES[i];
      throw SvnCommand.ex("Unsupported 'depth' value: '%s'", new Object[] { getValue() });
    }
  }
}

/* Location:           C:\Users\Administrator\Desktop\svnant.jar
 * Qualified Name:     org.tigris.subversion.svnant.commands.Checkout
 * JD-Core Version:    0.6.0
 */